# -*- coding: utf-8 -*-
"""
@author: wyb
@date: 2024/1/4
@time: 20:09
@desc: Description
"""
from pymongo import MongoClient

# client = pymongo.MongoClient(host='localhost', port=27017)
client = MongoClient('mongodb://admin:XY.2023.abcd@localhost:27017/admin')
db = client.course
list = db.students

# student1 = {
#     'id': '20170101',
#     'name': 'Jordan',
#     'age': 20,
#     'gender': 'male'
# }
#
# student2 = {
#     'id': '20170202',
#     'name': 'Mike',
#     'age': 21,
#     'gender': 'male'
# }
#
# result = list.insert_many([student1, student2])

result = list.find_one({"name": "Mike"}, {"name": 1, "age": 1})
print(result)

result = list.count_documents({'name':'Mike'})
print(result)